#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define FOR(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifdef zerol
#define dbg(x...) do { cout << "\033[32;1m" << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif


const LL MOD = 1e9+7;

const int N = 1e7+50;

int mu[N], prime[N], pcnt;
int minp[N];

int smu[N];

void init() {
    mu[1] = 1;
    for (int i=2; i<N; ++i) {
        if (!minp[i]) {
            minp[i] = i;
            prime[pcnt++] = i;
            mu[i] = -1;
        }
        for (int j=0; j<pcnt; ++j) {
            LL nextp = 1LL * i * prime[j];
            if (nextp >= N)
                break;
            if (!minp[nextp])
                minp[nextp] = prime[j];
            if (i % prime[j] == 0) {
                mu[nextp] = 0;
                break;
            } else {
                mu[nextp] = -mu[i];
            }
        }
    }
    for (int i=1; i<N; ++i)
        smu[i] = smu[i-1] + mu[i];
}

LL bin(LL a, LL b, LL p) {
    LL res = 1;
    a = (a%MOD+MOD)%MOD;
    for (; b; b>>=1, a=a*a%p)
        if (b & 1)
            res = res * a % p;

    return res;
}

LL s(LL x) {
    return 1LL * x * (x + 1) / 2 % MOD;
}

int n, k;
LL f(int nn) {
    LL ans = 0;
    for (int l=1, r, v; l<=nn; l=r+1) {
        v = nn / l;
        r = nn / v;
        // printf("f2: %d %lld\n", smu[r] - smu[l-1], bin(v, n, MOD));
        ans = (ans + (smu[r] - smu[l-1]) * bin(v, n, MOD)) % MOD;
    }
    // printf("f: %d %lld\n", n, ans);
    return ans;
}

int main() {
    // int t;
    scanf("%d%d", &n, &k);
    init();
    
    LL ans = 0;
    for (int l=1, r, v; l<=k; l=r+1) {
        v = k / l;
        r = k / v;
        r = min(r, k);
        LL del = 0;
        // printf("%d %d %d\n", l, r, v);
        // for (int j=1; j<=v; ++j) {
        //     del = (del + mu[j] * bin(v/j, n, MOD)) % MOD;
        // }

        ans = (ans + f(v) * (s(r) - s(l-1))) % MOD;
    }
    cout << (ans % MOD + MOD) % MOD << endl;
    return 0;
}
